/********************************************************************
filename : wolf_iic1_common.h
discript : there are more than one devices no I2C1 bus,this file include
					 common function for them.
version  : V0.0
editor   : Icy - dreamwolf
time     : 2014.3.2
statement: This file is modified by dreamwolf under LGPL,you could use 
           it free.We cann't ensure there is no error in this file,and
				   if you detect an error please contact us freely,it is so a-
					 ppreciate for your help to improve our code that could help 
					 more people to use it safty.
contact  : edreamtek@163.com
           www.edreamtek.com
********************************************************************/

#ifndef __WOLF_IIC1_COMMON_H__
#define __WOLF_IIC1_COMMON_H__

#include "stm32f0xx.h"
#include "wolf_typedefine.h"
#include "wolf32f031_board_pinmap.h"
#include "wolf_delay.h"

#define I2C_SLAVE_ADDRESS7				0xAA		
#define I2C_SPEED                 100000

#define ADDR_16_BITS							2
#define ADDR_8_BITS								1

#define sEE_I2C_TIMING          0x1045061D;//0x00210507




void wolf_iic1_init(void);

void wolf_iic1_write_byte(uint8_t device_addr,uint8_t addr_type,uint16_t dat_addr,uint8_t dat);

uint8_t wolf_iic1_read_byte(uint8_t device_addr,uint8_t addr_type,uint16_t dat_addr);

void wolf_iic_write_bytes(uint8_t device_addr,uint8_t addr_type,uint16_t dat_addr,uint8_t* pdat,uint16_t cnt);

void wolf_iic_read_bytes(uint8_t device_addr,uint8_t addr_type,uint16_t dat_addr,uint8_t* pdat,uint16_t cnt);



#define I2Cx                            I2C1
#define RCC_PERIPHCLK_I2Cx              RCC_PERIPHCLK_I2C1
#define RCC_I2CxCLKSOURCE_SYSCLK        RCC_I2C1CLKSOURCE_SYSCLK
#define I2Cx_CLK_ENABLE()               __I2C1_CLK_ENABLE()
#define I2Cx_SDA_GPIO_CLK_ENABLE()      __GPIOB_CLK_ENABLE()
#define I2Cx_SCL_GPIO_CLK_ENABLE()      __GPIOB_CLK_ENABLE() 

#define I2Cx_FORCE_RESET()              __I2C1_FORCE_RESET()
#define I2Cx_RELEASE_RESET()            __I2C1_RELEASE_RESET()

/* Definition for I2Cx Pins */
#define I2Cx_SCL_PIN                    GPIO_PIN_6
#define I2Cx_SCL_GPIO_PORT              GPIOB
#define I2Cx_SDA_PIN                    GPIO_PIN_7
#define I2Cx_SDA_GPIO_PORT              GPIOB
#define I2Cx_SCL_SDA_AF                 GPIO_AF1_I2C1

/* Definition for I2Cx's NVIC */
#define I2Cx_IRQn                    I2C1_IRQn
#define I2Cx_IRQHandler              I2C1_IRQHandler



#endif

